/**
 * 
 */
package ar.com.sebasoft.prestalibro.persistence;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.content.Context;
import ar.com.sebasoft.prestalibro.model.Socio;
import ar.com.sebasoft.prestalibro.view.util.SessionInViewManager;

import com.j256.ormlite.dao.RuntimeExceptionDao;

/**
 * @author SebaSOFT
 * 
 */
public class SocioDBManager {
	private SessionInViewManager session = null;

	public SocioDBManager(Context ctx) {
		this.session = SessionInViewManager.getInstance(ctx);
	}

	public Socio getSocioByEmailAndClave(String email, String clave) {
		Socio res = null;
		Map<String, Object> params = new HashMap<String, Object>();

		params.put("email", email);
		params.put("clave", clave);

		List<Socio> resList = this.getSocioDao().queryForFieldValues(params);
		if (resList.size() > 0) {
			res = resList.get(0);
		}

		return res;
	}

	private RuntimeExceptionDao<Socio, Integer> getSocioDao() {
		return this.session.getDbHelper().getSocioDao();
	}
}
